<!DOCTYPE html>

<html>
<head>
    <title>交易席位</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <link rel="stylesheet" href="../css/theme9.css">
    <script src="../lib/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script src="../lib/layuimini/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]-->
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <!--下列表格要导入的文件-->
    <link rel="stylesheet" href="../lib/layuimini/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../lib/layuimini/css/public.css" media="all">
    <script src="../lib/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
    <script src="../lib/layuimini/js/lay-config.js?v=1.0.4" charset="utf-8"></script>


    <!--工具条-->
    <script type="text/html" id="userToolBar">
        <div style="float:right">
            <button class="layui-btn layui-btn layui-btn-sm" lay-event="add"><i
                    class="layui-icon">&#xe654;</i>添加数据</button>
            <button class="layui-btn layui-btn-danger layui-btn layui-btn-sm" lay-event="deleteAll"><i
                    class="layui-icon">&#xe640;</i>批量删除</button>
        </div>
        <br/>
        <form class="layui-form layui-col-space5">
            <div class="layui-inline layui-show-xs-block">
                <label class="layui-form-label layui-bg-green" style="width: 90px;text-align: center">席位名称</label>
                <div class="layui-inline layui-show-xs-block">
                    <input type="text"  style="width: 130px" name="seateName" id="seateName" placeholder="请输入席位名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-show-xs-block">
                <label class="layui-form-label layui-bg-green" style="width: 90px;text-align: center">席位类型</label>
                <div class="layui-inline layui-show-xs-block">
                    <select name="modules" id="modules" lay-search="" lay-verify="required" style="width: 130px">
                        <option value="">--请选择--</option>
                        <option value="1">贵宾</option>
                        <option value="2">普通</option>
                    </select>
                </div>
            </div>

            <div class="layui-inline layui-show-xs-block">
                <label class="layui-form-label layui-bg-green" style="width: 90px;text-align: center">券商ID</label>
                <div class="layui-inline layui-show-xs-block">
                    <input type="text" style="width: 130px" name="brokersId" id="brokersId" placeholder="请输入券商ID" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-inline layui-show-xs-block">
                <button class="layui-btn" lay-event="search" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索</button>
            </div>
        </form>
    </script>




</head>
<body style="overflow: auto; background-color: white;"
      class="layui-view-body layui-content">
<div>
    <!--表格-->
    <table id="userTable" lay-filter="userTable"></table>
    <!--工具条-->
    <div style="display: none;" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit"><i
                class="layui-icon">&#xe642;</i>编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
                class="layui-icon">&#xe640;</i>删除</a>

    </div>
</div>


<!--增加的div内容-->
<div id="addContent"  style="display: none; height: 100%; height: 100%; text-align: center;">
    <form id="addform" lay-filter="addform" class="layui-form layui-col-space5"  style="margin: 30px auto; display: inline-block;">
        <div>
            <div class="layui-row">
                <div class="layui-col-xs6">

                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位名称</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位名称" name="seateName">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位编号</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位编号" name="seateId">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位类型</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位类型" name="seateType">
                        </div>
                    </div>
                </div>


                <div class="layui-col-xs6">
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">佣金利率(%)</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入佣金利率(%)" name="seateRate">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">劵商名称</label>
                        <div class="layui-inline layui-show-xs-block">

                            <input class="layui-input" placeholder="请输入劵商名称" name="brokersName" id="insertBrokers">
                            <input type="hidden" name="brokersId" id="brokersId1">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位地址</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位地址" name="seateAddress">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center;">

                <div class="layui-input-inline">
                    <textarea name="seateDesc" style="width: 590px;height: 100px;padding: 10px;" rows="" cols="" placeholder="备注"></textarea>
                </div>
            </div>
        </div>
        <div style="position: absolute; left: 35%; bottom: 18px;">
            <button class="layui-btn" lay-submit="add" lay-filter="addsubmit">
                <i class="layui-icon">&#x1005;</i>新增
            </button>
            <button class="layui-btn layui-bg-red cancel" type="button" onclick="myclose()">
                <i class="layui-icon">&#x1006;</i>取消
            </button>
        </div>

       <!-- <div class="layui-inline layui-show-xs-block" style="text-align: center;">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位名称</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位名称" name="seateName">
            </div>
        </div>


        <div class="layui-inline layui-show-xs-block" style="text-align: center">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位编号</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位编号" name="seateId">
            </div>
        </div>


        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位类型</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位类型" name="seateType">
            </div>
        </div>
        <br>
        <br>
        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">佣金利率(%)</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入佣金利率(%)" name="seateRate">
            </div>
        </div>


        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">劵商名称</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入劵商名称" name="brokersId" id="brokers">
            </div>
        </div>
        <br>
        <br>

        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位地址</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位地址" name="seateAddress">
            </div>
        </div>
        <br>
        <br>
        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center; width: 80px; height: 20px">备注</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入" name="seateDesc"  style="width: 600px;height: 95px">
            </div>
        </div>

        <div style="position: absolute; bottom: 0px; left: 35%;">
            <button class="layui-btn" lay-submit="" lay-filter="addsubmit">
                <i class="layui-icon">&#x1005;</i>添加
            </button>
            <button class="layui-btn layui-bg-red cancel" type="button" onclick="myclose()">
                <i class="layui-icon">&#x1006;</i>取消
            </button>
        </div>-->
    </form>
</div>


<!--修改的div内容-->
<div id="editContent"
     style="display: none; height: 100%; height: 100%; text-align: center;">
    <form id="editform" lay-filter="editform"
          class="layui-form layui-form-pane"
          style="margin: 30px auto; display: inline-block;">
        <div>
            <div class="layui-row">
                <div class="layui-col-xs6">

                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位名称</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位名称" name="seateName">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位编号</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位编号" name="seateId">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位类型</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位类型" name="seateType">
                        </div>
                    </div>
                </div>


                <div class="layui-col-xs6">
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">佣金利率(%)</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入佣金利率(%)" name="seateRate">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">劵商名称</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入劵商名称" name="brokersName" id="updateBrokers">
                            <input type="hidden"  name="brokersId" id="brokersId2">
                        </div>
                    </div>
                    <div class="layui-form-item" style="text-align: center;">
                        <label class="layui-form-label layui-bg-green" style="text-align: center">席位地址</label>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" placeholder="请输入席位地址" name="seateAddress">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center;">

                <div class="layui-input-inline">
                    <textarea name="seateDesc" style="width: 590px;height: 100px;padding: 10px;" rows="" cols="" placeholder="备注"></textarea>
                </div>
            </div>
        </div>
        <div style="position: absolute; left: 35%; bottom: 18px;">
            <button class="layui-btn" lay-submit="" lay-filter="editsubmit">
                <i class="layui-icon">&#x1005;</i>修改
            </button>
            <button class="layui-btn layui-bg-red cancel" type="button" onclick="myclose()">
                <i class="layui-icon">&#x1006;</i>取消
            </button>
        </div>
    </form>
</div>



<!--<div id="editContent1"
     style="display: none; height: 100%; height: 100%; text-align: center">
    <form id="editform1" lay-filter="editform"
          class="layui-form layui-form-pane"
          style="margin: 30px auto; display: inline-block">
        <div class="layui-inline layui-show-xs-block" style="text-align: center">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位名称</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位名称" name="seateName">
            </div>
        </div>

        <div class="layui-inline layui-show-xs-block" style="text-align: center">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位编号</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位编号" name="seateId">
            </div>
        </div>


        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位类型</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位类型" name="seateType">
            </div>
        </div>
        <br>
        <br>
        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">佣金利率(%)</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入佣金利率(%)" name="seateRate">
            </div>
        </div>


        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">劵商名称</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入劵商名称" name="brokersId">
            </div>
        </div>
        <br>
        <br>

        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center">席位地址</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入席位地址" name="seateAddress">
            </div>
        </div>
        <br>
        <br>
        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-green" style="text-align: center; width: 80px; height: 20px">备注</label>
            <div class="layui-inline layui-show-xs-block">
                <input class="layui-input" placeholder="请输入" name="seateDesc"  style="width: 600px;height: 95px">
            </div>
        </div>
        <div style="position: absolute; bottom: 0px; left: 35%;">
            <button class="layui-btn" lay-submit="" lay-filter="addsubmit">
                <i class="layui-icon">&#x1005;</i>添加
            </button>
            <button class="layui-btn layui-bg-red cancel" type="button" onclick="myclose()">
                <i class="layui-icon">&#x1006;</i>取消
            </button>
        </div>
    </form>
</div>-->
<script type="text/javascript">

    layui.use(['element', 'form', 'table', 'layer', 'laydate','tableSelect'], function () {
        var layer = layui.layer;
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var tableSelect = layui.tableSelect;
        var laydate = layui.laydate;

        //新增提交
        form.on('submit(addsubmit)', function(data){
            var formData=$('#addform').serialize();
            $.post("../seateInsert",formData,function(msg){
                if(msg>0){
                    table.reload('userTable');
                    layer.closeAll();
                    layer.msg('添加成功',{
                        title : '提示',
                        area : [ '200px',
                            '140px' ],
                        time : 0,
                        btn : [ '知道了' ]
                    });
                }else{
                    layer.closeAll();
                    layer.msg('添加成功',{
                        title : '提示',
                        area : [ '200px',
                            '140px' ],
                        time : 0,
                        btn : [ '知道了' ]
                    });
                }
            });

            //表格的重新加载事件
            table.reload('userTable');
            return false;
        });
        //修改提交
        form.on('submit(editsubmit)', function(data){
            var formData=$('#editform').serialize();
            $.post("../seateUpdate",formData,function(msg){
                if(msg>0){
                    table.reload('userTable');
                    layer.closeAll();
                    layer.msg('修改成功',{
                        title : '提示',
                        area : [ '200px',
                            '140px' ],
                        time : 0,
                        btn : [ '知道了' ]
                    });
                }else{
                    layer.closeAll();
                    layer.msg('修改失败',{
                        title : '提示',
                        area : [ '200px',
                            '140px' ],
                        time : 0,
                        btn : [ '知道了' ]
                    });
                }
            });
            return false;
        });
        table.render({
            elem: '#userTable',
            url: '../seateSelect',
            page: true,
            height:'full-75',
            toolbar: '#userToolBar',//显示在表头的工具条
            cellMinWidth: 60,
            cols: [
                [ //表头
                    {type: 'checkbox', fixed: 'left'}
                    ,{field: 'seateId', title: '席位编号',width:128,  align:'center'}
                    ,{field: 'seateName', title: '席位名称',width:128,  align:'center'}
                    ,{field: 'seateType', title: '席位类型', width:128,  align:'center',
                    templet:function (item) {
                        if(item.seateType==1){
                            return '贵宾'
                        }else if(item.seateType==2){}
                        return '普通'
                    }}
                    ,{field: 'seateRate', title: '佣金利率(%)', width:128 ,align:'center'}
                    ,{field: 'brokersId', title: '劵商编号', width:128 , align:'center'}
                    ,{field: 'brokersName', title: '劵商名称', width:128 , align:'center'}
                    ,{field: 'seateAddress', title: '席位地址', width:128 , align:'center',
                    templet:function (item) {
                        if(item.seateAddress==1){
                            return '上海'
                        }else if(item.seateAddress==2){}
                        return '深圳'
                    }}
                    ,{field: 'seateDesc', title: '备注',  width:128 ,align:'center'}
                    ,{title: 'operation', title: '操作' ,toolbar:'#barDemo', align:'center'}
                ]
            ]
        });
        //给工具条的按钮添加事件
        table.on('toolbar(userTable)',function (obj) {
            //获取选中复选框的对象，
            var checkStatus=table.checkStatus(obj.config.id);//得到表格选中行的ID
            switch (obj.event) {
                case 'add':
                    var index=layer.open({
                        type: 1,
                        title: '添加数据信息',
                        closeBtn: 1,
                        move:false,
                        area: ['800px', '650px'],
                        content:$("#addContent"),
                        btn:[]
                    });
                    form.render();
                    //全屏
                    //layer.full(index);
                    break;
                case 'search':
                    //alert("搜索");

                    var seateName= $("#seateName").val();
                    var brokersId= $("#brokersId").val();
                    var modules= $("#modules").val();
                    //alert(seateName);
                    //表格的重新加载事件
                    table.reload('userTable', {
                        method: 'post'
                        , where: {
                            'seateName': seateName,
                            'brokersId': brokersId,
                            'modules': modules
                        }
                        , page: {
                            curr: 1
                        }
                    });

                    break;
                case 'deleteAll':
                    var data = checkStatus.data;
                    //    layer.alert(JSON.stringify(data));
                    if(data.length==0){
                        layer.msg("请至少选择一条数据",)
                    }else
                    {
                        var ids=[];
                        for (var i = 0; i <data.length; i++) {
                            ids.push(data[i].seateId);
                        }
                        layer.confirm('真的删除行么',{icon: 2}, function(index){
                            layer.close(index);
                            $.post("../seateDelete", {seateId:ids.join(',')},function(msg){
                                table.reload('userTable');
                                layer.msg('删除'+checkStatus.data.length+'条记录', {
                                    title:'提示',
                                    area: ['200px', '140px'],
                                    time: 0,
                                    btn: ['知道了']
                                });
                            });
                        });
                    }
                    break;
            }
        });
        //给表格编辑，删除按钮添加点击事件
        table.on('tool(userTable)', function(obj) {
            var data = obj.data;//得到删除行整行的数据
            if (obj.event === 'del') {
                layer.confirm('真的删除行么',{icon: 2}, function(index){

                    layer.close(index);
                    $.post("../seateDelete", {seateId:data.seateId+""},function(msg){
                        table.reload('userTable');
                    });

                });
            } else if (obj.event === 'edit') {
                form.val('editform',$.parseJSON(JSON.stringify(data)));
                var index = layer.open({
                    type: 1,
                    title: '修改权益数据',
                    closeBtn: 1,
                    move:false,
                    area: ['630px', '650px'],
                    content:$('#editContent')
                });
                form.render();
                //layer.full(index);
            };
        })
        //给修改券商的下拉表格
        tableSelect.render({
            elem:'#updateBrokers',
            checkedKey:'brokersId',
            table:{
                url:'../brokersSelect',
                cellMinWidth: 60,
                cols:[
                    [   {type:'radio'},
                        {field:'brokersId',title:'券商编号',width:200},
                        {field: 'brokersName',title:'券商名称',width: 200},
                    ]
                ]
            },
            done:function (elem,data) {
                //elem:返回之前input对象；data:表格返回的选中的数据 []
                var newJson=[];
                //遍历选中的数据
                $.each(data.data,function (index,item) {
                    newJson.push(item.brokersName);
                    alert(item.brokersId)
                    $("#brokersId2").val(item.brokersId);
                });
                elem.val(newJson.join(","));//给输入框里显示的值赋值

            }
        })
        //新增券商的下拉表格
        tableSelect.render({
            elem:'#insertBrokers',
            checkedKey:'brokersId',
            table:{
                url:'../brokersSelect',
                cellMinWidth: 60,
                cols:[
                    [   {type:'radio'},
                        {field:'brokersId',title:'券商编号',width:200},
                        {field: 'brokersName',title:'券商名称',width: 200},
                    ]
                ]
            },
            done:function (elem,data) {
                //elem:返回之前input对象；data:表格返回的选中的数据 []
                var newJson=[];
                //遍历选中的数据
                $.each(data.data,function (index,item) {
                    newJson.push(item.brokersName);
                    $("#brokersId1").val(item.brokersId);
                });
                elem.val(newJson.join(","));//给输入框里显示的值赋值
            }
        })
    });
    function myclose() {
        layer.closeAll();
    }
</script>
</body>
</html>
